import axiosx from "./util/axiosx"
import md5 from "md5"
import base from "./util/base";

export default {
    login() {
        axiosx.request({
            method: "post",
            url: "/back/user/center/login",
            data: {
                "passwordStr": md5("123456"),
                // "passwordStr": md5('admin'),
                "phoneStr": "admin"
            }
        }).then(res => {
            base.setToken(res);
        });
    },
    refresh() {
        base.refreshApi = true;
        base.refreshed = false;
        axiosx.request({
            method: "post",
            url: "/base/refresh"
        }).then(res => {
            console.log(111111, res);
            if (res && res.data && res.data.authorization) {
                base.setToken(res.data.authorization);
            }
        }).catch(reason => {
            console.log(2222, reason);
        }).finally(() => {
            base.refreshApi = false;
        })
    },
    findCourse() {
        axiosx.request({
            method: "post",
            url: "/course/find",
            data: {
                "pageSize": 2,
                "pageIndex": 1
            }
        }).then(res => {
            console.log("findCourse 方法返回结果", res);
        })/*.catch(reason => {
            console.log('findCourse 方法返回结果异常',reason);
        })*/;
    },
    findRole() {
        axiosx.request({
            method: "post",
            url: "/role/find",
            data: {
                "pageSize": 2,
                "pageIndex": 1
            }
        }).then(res => {
            console.log("findRole 方法返回结果", res);
        }).catch(reason => {
            console.log("findRole 方法返回结果异常", reason);
        });
    },
    check() {
        console.log(base.checkType({}), typeof {});
        console.log(base.checkType([]), typeof []);
        console.log(base.checkType("asdf"), typeof "asdf");
        console.log(base.checkType(1), typeof 1);
        console.log(base.checkType(1.1), typeof 1.1);
        console.log(base.checkType(true), typeof true);
        console.log(base.checkType(null), typeof null);
        console.log(base.checkType(undefined), typeof undefined);
        console.log(base.checkType(function () {
        }), typeof function () {
        });
    },
    ls() {
        base.lsPut("xxxxx", "qqqqqqqq");
        console.log(base.lsGet("xxxxx"));
        base.setToken("token")
        console.log(base.getToken());
    },
    arrows: () => {
        console.log(this);
    }
}

